{% if page.comments != false %}
  {% case site.comments_provider %}
    {% when 'disqus' %}
      {% if site.disqus_username %}
        {% assign load_disqus = true %}
        <!-- Disqus Protection, see https://github.com/mzlogin/mzlogin.github.io/issues/2 -->
        {% if site.disqus_username == 'mzlogin' %}
          {% assign load_disqus = false %}
          {% if site.url contains 'mazhuang.org' %}
            {% assign load_disqus = true %}
          {% endif %}
        {% endif %}
        {% if load_disqus %}
          <div id="disqus_thread"></div>
          <script>
            var disqus_config = function () {
              this.page.url = '{{ site.url }}{{ page.url }}';
              this.page.identifier = '{{ page.url }}';
              this.page.title = '{{ page.title }}';
            };
            (function() { // DON'T EDIT BELOW THIS LINE
              var d = document, s = d.createElement('script');

              s.type = 'text/javascript';
              s.async = true;
              var shortname = '{{ site.disqus_username }}';

              s.src = '//' + shortname + '.disqus.com/embed.js';

              s.setAttribute('data-timestamp', +new Date());
              (d.head || d.body).appendChild(s);
            })();
          </script>
          <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
        {% endif %}
        {% if site.lazy_load_duoshuo and site.duoshuo_username %}
        <a href="#" class="show_duoshuo_comment" onclick="return false;" style="color:rgba(30,55,70,.4);font-size:0.75em;">想留言却没看到评论框？点这里。</a>
        <!-- Duoshuo Comment BEGIN -->
        <!-- 多说评论框 BEGIN -->
        <div class="ds-thread" data-thread-key="{{ page.url }}" data-title="{{ page.title }}" data-url="{{ site.url }}{{ page.url }}"></div>
        <!-- 多说评论框 END -->
        <!-- 多说公共JS代码 BEGIN (一个网页只需插入一次) -->
        <script type="text/javascript">
        var duoshuoQuery = {short_name:"{{ site.duoshuo_username }}"};
        $(function() {
            $('.show_duoshuo_comment').on('click', function() {
                $(this).html('加载中...');
                var that = this;
                var src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
                $.getScript(src, function(){$(that).remove()});
            })
        })
        </script>
        <!-- 多说公共JS代码 END -->
        <!-- Duoshuo Comment END -->
        {% endif %}
      {% endif %}
    {% when 'duoshuo' %}
      {% if site.duoshuo_username %}
      <!-- Duoshuo Comment BEGIN -->
      <!-- 多说评论框 BEGIN -->
      <div class="ds-thread" data-thread-key="{{ page.url }}" data-title="{{ page.title }}" data-url="{{ site.url }}{{ page.url }}"></div>
      <!-- 多说评论框 END -->
      <!-- 多说公共JS代码 BEGIN (一个网页只需插入一次) -->
      <script type="text/javascript">
      var duoshuoQuery = {short_name:"{{ site.duoshuo_username }}"};
        (function() {
          var ds = document.createElement('script');
          ds.type = 'text/javascript';ds.async = true;
          ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
          ds.charset = 'UTF-8';
          (document.getElementsByTagName('head')[0]
           || document.getElementsByTagName('body')[0]).appendChild(ds);
        })();
        </script>
      <!-- 多说公共JS代码 END -->
      <!-- Duoshuo Comment END -->
      {% endif %}
  {% endcase %}
{% endif %}
